
<?php
			  function paging($totalRows,$curPg,$pg,$re)	  
				{						
				$paging="";	         		 
				$mxR = $re;
				$mxP = $pg;
				if($totalRows%$mxR==0)  
					$totalPages = (int)($totalRows/$mxR);
				else 
					$totalPages = (int)($totalRows/$mxR+1);

				
				$curRow = ($curPg-1)*$mxR+1;
				$paging ="Current Page :&nbsp;";
				$paging .="<font color=red>".$curPg;
				$paging .="</font>&nbsp;&nbsp;&nbsp;";
				$paging .="Total pages :&nbsp;";
				$paging .="<FONT color=red>";
				$paging .=$totalPages."</FONT><br> "; 
				if($totalRows>$mxR)
					{
				 	$start=1;
				 	$end=1;
				 	$paging1 ="";				 	 
					for($i=1;$i<=$totalPages;$i++)
					{	if(($i>((int)(($curPg-1)/$mxP))* $mxP) && ($i<=((int)(($curPg-1)/$mxP+1))* $mxP))
						{
							if($start==1) $start=$i;
							if($i==$curPg)      
							  	$paging1 .=  $i."&nbsp;&nbsp;";
							else    
								{
							  	$paging1 .= "<a href='";
								$paging1 .="../User/BookInfor.php?p=".$i."'>".$i;
								$paging1 .="</a>&nbsp;&nbsp;";	
								}
							$end=$i;	
						}
					}
					$paging.= "Go to page :&nbsp;&nbsp;" ;
					if($curPg>$mxP)
						{
					 	$paging .="<a href=";
						$paging .="'../User/BookInfor.php?p=".($start-1);
						$paging .="'>Previous</a>&nbsp;&nbsp;";
						}
					$paging.=$paging1;
					if((((int)(($curPg-1)/$mxP+1))*$mxP) < $totalPages)
						{
						$paging .= "<a href=";
						$paging .="'../User/BookInfor.php?p=".($end+1);
						$paging .="'>Next</a>&nbsp;&nbsp;";
						}
					}
				 return $paging;
			}
			 	?>